<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python documentation Index' />
<link rel="first" href="lib.html" title='Python library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="datetime-tzinfo.html" />
<link rel="prev" href="datetime-datetime.html" />
<link rel="parent" href="module-datetime.html" />
<link rel="next" href="datetime-tzinfo.html" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name='aesop' content='information' />
<title>5.1.5 time Objects </title>
</head>
<body>
<div class="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="5.1.4 datetime Objects"
  href="datetime-datetime.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="5.1 datetime  "
  href="module-datetime.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="5.1.6 tzinfo Objects"
  href="datetime-tzinfo.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="datetime-datetime.html">5.1.4 datetime Objects</a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-datetime.html">5.1 datetime  </a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="datetime-tzinfo.html">5.1.6 tzinfo Objects</a>
</div>
<hr /></div>
</div>
<!--End of Navigation Panel-->

<h2><a name="SECTION007150000000000000000"></a><a name="datetime-time"></a>
<br>
5.1.5 <tt class="class">time</tt> Objects 
</h2>

<p>
A time object represents a (local) time of day, independent of any
particular day, and subject to adjustment via a <tt class="class">tzinfo</tt> object.

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><span class="typelabel">class</span>&nbsp;<tt id='l2h-672' xml:id='l2h-672' class="class">time</tt></b>(</nobr></td>
  <td><var>hour</var><big>[</big><var>, minute</var><big>[</big><var>, second</var><big>[</big><var>,
                        microsecond</var><big>[</big><var>, tzinfo</var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
  All arguments are optional.  <var>tzinfo</var> may be <code>None</code>, or
  an instance of a <tt class="class">tzinfo</tt> subclass.  The remaining arguments
  may be ints or longs, in the following ranges:

<p>

<ul>
<li><code>0 &lt;= <var>hour</var> &lt; 24</code>
</li>
<li><code>0 &lt;= <var>minute</var> &lt; 60</code>
</li>
<li><code>0 &lt;= <var>second</var> &lt; 60</code>
</li>
<li><code>0 &lt;= <var>microsecond</var> &lt; 1000000</code>.
  
</li>
</ul>

<p>
If an argument outside those ranges is given,
  <tt class="exception">ValueError</tt> is raised.  All default to <code>0</code> except
  <var>tzinfo</var>, which defaults to <tt class="constant">None</tt>.
</dl>

<p>
Class attributes:

<p>
<dl><dt><b><tt id='l2h-673' xml:id='l2h-673' class="member">min</tt></b></dt>
<dd>
  The earliest representable <tt class="class">time</tt>, <code>time(0, 0, 0, 0)</code>.
</dl>

<p>
<dl><dt><b><tt id='l2h-674' xml:id='l2h-674' class="member">max</tt></b></dt>
<dd>
  The latest representable <tt class="class">time</tt>, <code>time(23, 59, 59, 999999)</code>.
</dl>

<p>
<dl><dt><b><tt id='l2h-675' xml:id='l2h-675' class="member">resolution</tt></b></dt>
<dd>
  The smallest possible difference between non-equal <tt class="class">time</tt>
  objects, <code>timedelta(microseconds=1)</code>, although note that
  arithmetic on <tt class="class">time</tt> objects is not supported.
</dl>

<p>
Instance attributes (read-only):

<p>
<dl><dt><b><tt id='l2h-676' xml:id='l2h-676' class="member">hour</tt></b></dt>
<dd>
  In <code>range(24)</code>.
</dl>

<p>
<dl><dt><b><tt id='l2h-677' xml:id='l2h-677' class="member">minute</tt></b></dt>
<dd>
  In <code>range(60)</code>.
</dl>

<p>
<dl><dt><b><tt id='l2h-678' xml:id='l2h-678' class="member">second</tt></b></dt>
<dd>
  In <code>range(60)</code>.
</dl>

<p>
<dl><dt><b><tt id='l2h-679' xml:id='l2h-679' class="member">microsecond</tt></b></dt>
<dd>
  In <code>range(1000000)</code>.
</dl>

<p>
<dl><dt><b><tt id='l2h-680' xml:id='l2h-680' class="member">tzinfo</tt></b></dt>
<dd>
  The object passed as the tzinfo argument to the <tt class="class">time</tt>
  constructor, or <code>None</code> if none was passed.
</dl>

<p>
Supported operations:

<p>

<ul>
<li>comparison of <tt class="class">time</tt> to <tt class="class">time</tt>,
    where <var>a</var> is considered less than <var>b</var> when <var>a</var> precedes
    <var>b</var> in time.  If one comparand is naive and the other is aware,
    <tt class="exception">TypeError</tt> is raised.  If both comparands are aware, and
    have the same <tt class="member">tzinfo</tt> member, the common <tt class="member">tzinfo</tt>
    member is ignored and the base times are compared.  If both
    comparands are aware and have different <tt class="member">tzinfo</tt> members,
    the comparands are first adjusted by subtracting their UTC offsets
    (obtained from <code>self.utcoffset()</code>).
    In order to stop mixed-type comparisons from falling back to the
    default comparison by object address, when a <tt class="class">time</tt> object is
    compared to an object of a different type, <tt class="exception">TypeError</tt> is
    raised unless the comparison is <code>==</code> or <code>!=</code>.  The latter
    cases return <tt class="constant">False</tt> or <tt class="constant">True</tt>, respectively.

<p>
</li>
<li>hash, use as dict key

<p>
</li>
<li>efficient pickling

<p>
</li>
<li>in Boolean contexts, a <tt class="class">time</tt> object is considered to be
    true if and only if, after converting it to minutes and
    subtracting <tt class="method">utcoffset()</tt> (or <code>0</code> if that's
    <code>None</code>), the result is non-zero.
</li>
</ul>

<p>
Instance methods:

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-681' xml:id='l2h-681' class="method">replace</tt></b>(</nobr></td>
  <td><var></var><big>[</big><var>hour</var><big>[</big><var>, minute</var><big>[</big><var>,
                            second</var><big>[</big><var>, microsecond</var><big>[</big><var>,
                            tzinfo</var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
  Return a <tt class="class">time</tt> with the same value, except for those members given
  new values by whichever keyword arguments are specified.  Note that
  <code>tzinfo=None</code> can be specified to create a naive <tt class="class">time</tt> from
  an aware <tt class="class">time</tt>, without conversion of the time members.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-682' xml:id='l2h-682' class="method">isoformat</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
  Return a string representing the time in ISO 8601 format,
      HH:MM:SS.mmmmmm
  or, if self.microsecond is 0,
      HH:MM:SS
  If <tt class="method">utcoffset()</tt> does not return <code>None</code>, a 6-character
  string is appended, giving the UTC offset in (signed) hours and
  minutes:
      HH:MM:SS.mmmmmm+HH:MM
  or, if self.microsecond is 0,
      HH:MM:SS+HH:MM
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-683' xml:id='l2h-683' class="method">__str__</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
  For a time <var>t</var>, <code>str(<var>t</var>)</code> is equivalent to
  <code><var>t</var>.isoformat()</code>.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-684' xml:id='l2h-684' class="method">strftime</tt></b>(</nobr></td>
  <td><var>format</var>)</td></tr></table></dt>
<dd>
  Return a string representing the time, controlled by an explicit
  format string.  See section&nbsp;<a href="strftime-behavior.html#strftime-behavior">5.1.7</a> -
  <tt class="method">strftime()</tt> behavior.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-685' xml:id='l2h-685' class="method">utcoffset</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
  If <tt class="member">tzinfo</tt> is <code>None</code>, returns <code>None</code>, else
  returns <code><var>self</var>.tzinfo.utcoffset(None)</code>, and
  raises an exception if the latter doesn't return <code>None</code> or
  a <tt class="class">timedelta</tt> object representing a whole number of minutes
  with magnitude less than one day.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-686' xml:id='l2h-686' class="method">dst</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
  If <tt class="member">tzinfo</tt> is <code>None</code>, returns <code>None</code>, else
  returns <code><var>self</var>.tzinfo.dst(None)</code>, and
  raises an exception if the latter doesn't return <code>None</code>, or
  a <tt class="class">timedelta</tt> object representing a whole number of minutes
  with magnitude less than one day.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-687' xml:id='l2h-687' class="method">tzname</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
  If <tt class="member">tzinfo</tt> is <code>None</code>, returns <code>None</code>, else
  returns <code><var>self</var>.tzinfo.tzname(None)</code>, or
  raises an exception if the latter doesn't return <code>None</code> or
  a string object.
</dl>

<p>

<div class="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="5.1.4 datetime Objects"
  href="datetime-datetime.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="5.1 datetime  "
  href="module-datetime.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="5.1.6 tzinfo Objects"
  href="datetime-tzinfo.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="datetime-datetime.html">5.1.4 datetime Objects</a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-datetime.html">5.1 datetime  </a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="datetime-tzinfo.html">5.1.6 tzinfo Objects</a>
</div>
</div>
<hr />
<span class="release-info">Release 2.5.1, documentation updated on 18th April, 2007.</span>
</div>
<!--End of Navigation Panel-->
<address>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</address>
</body>
</html>
